// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.MachineLearning;

public sealed partial class PutJobRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Create an anomaly detection job.
/// If you include a <c>datafeed_config</c>, you must have read index privileges on the source index.
/// </para>
/// </summary>
public sealed partial class PutJobRequest : PlainRequest<PutJobRequestParameters>
{
	public PutJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Required("job_id", jobId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutJob;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_job";

	/// <summary>
	/// <para>
	/// Advanced configuration option. Specifies whether this job can open when there is insufficient machine learning node capacity for it to be immediately assigned to a node. By default, if a machine learning node with capacity to run the job cannot immediately be found, the open anomaly detection jobs API returns an error. However, this is also subject to the cluster-wide <c>xpack.ml.max_lazy_ml_nodes</c> setting. If this option is set to true, the open anomaly detection jobs API does not return an error and the job waits in the opening state until sufficient machine learning node capacity is available.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("allow_lazy_open")]
	public bool? AllowLazyOpen { get; set; }

	/// <summary>
	/// <para>
	/// Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("analysis_config")]
	public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfig AnalysisConfig { get; set; }

	/// <summary>
	/// <para>
	/// Limits can be applied for the resources required to hold the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("analysis_limits")]
	public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits? AnalysisLimits { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. The time between each periodic persistence of the model. The default value is a randomized value between 3 to 4 hours, which avoids all jobs persisting at exactly the same time. The smallest allowed value is 1 hour. For very large models (several GB), persistence could take 10-20 minutes, so do not set the <c>background_persist_interval</c> value too low.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("background_persist_interval")]
	public Elastic.Clients.Elasticsearch.Duration? BackgroundPersistInterval { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. Contains custom meta data about the job.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("custom_settings")]
	public object? CustomSettings { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies a period of time (in days) after which only the first snapshot per day is retained. This period is relative to the timestamp of the most recent snapshot for this job. Valid values range from 0 to <c>model_snapshot_retention_days</c>.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("daily_model_snapshot_retention_after_days")]
	public long? DailyModelSnapshotRetentionAfterDays { get; set; }

	/// <summary>
	/// <para>
	/// Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post data API, it is not stored in Elasticsearch. Only the results for anomaly detection are retained.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("data_description")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataDescription DataDescription { get; set; }

	/// <summary>
	/// <para>
	/// Defines a datafeed for the anomaly detection job. If Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had at the time of creation and runs the query using those same roles. If you provide secondary authorization headers, those credentials are used instead.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("datafeed_config")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfig? DatafeedConfig { get; set; }

	/// <summary>
	/// <para>
	/// A description of the job.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>
	/// A list of job groups. A job can belong to no groups or many.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("groups")]
	public ICollection<string>? Groups { get; set; }

	/// <summary>
	/// <para>
	/// This advanced configuration option stores model information along with the results. It provides a more detailed view into anomaly detection. If you enable model plot it can add considerable overhead to the performance of the system; it is not feasible for jobs with many entities. Model plot provides a simplified and indicative view of the model and its bounds. It does not display complex features such as multivariate correlations or multimodal data. As such, anomalies may occasionally be reported which cannot be seen in the model plot. Model plot config can be configured when the job is created or updated later. It must be disabled if performance issues are experienced.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("model_plot_config")]
	public Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? ModelPlotConfig { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies the maximum period of time (in days) that snapshots are retained. This period is relative to the timestamp of the most recent snapshot for this job. By default, snapshots ten days older than the newest snapshot are deleted.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("model_snapshot_retention_days")]
	public long? ModelSnapshotRetentionDays { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period over which adjustments to the score are applied, as new data is seen. The default value is the longer of 30 days or 100 bucket spans.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("renormalization_window_days")]
	public long? RenormalizationWindowDays { get; set; }

	/// <summary>
	/// <para>
	/// A text string that affects the name of the machine learning results index. By default, the job generates an index named <c>.ml-anomalies-shared</c>.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("results_index_name")]
	public Elastic.Clients.Elasticsearch.IndexName? ResultsIndexName { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period of time (in days) that results are retained. Age is calculated relative to the timestamp of the latest bucket result. If this property has a non-null value, once per day at 00:30 (server time), results that are the specified number of days older than the latest bucket result are deleted from Elasticsearch. The default value is null, which means all results are retained. Annotations generated by the system also count as results for retention purposes; they are deleted after the same number of days as results. Annotations added by users are retained forever.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("results_retention_days")]
	public long? ResultsRetentionDays { get; set; }
}

/// <summary>
/// <para>
/// Create an anomaly detection job.
/// If you include a <c>datafeed_config</c>, you must have read index privileges on the source index.
/// </para>
/// </summary>
public sealed partial class PutJobRequestDescriptor<TDocument> : RequestDescriptor<PutJobRequestDescriptor<TDocument>, PutJobRequestParameters>
{
	internal PutJobRequestDescriptor(Action<PutJobRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public PutJobRequestDescriptor(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Required("job_id", jobId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutJob;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_job";

	public PutJobRequestDescriptor<TDocument> JobId(Elastic.Clients.Elasticsearch.Id jobId)
	{
		RouteValues.Required("job_id", jobId);
		return Self;
	}

	private bool? AllowLazyOpenValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfig AnalysisConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor<TDocument> AnalysisConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor<TDocument>> AnalysisConfigDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits? AnalysisLimitsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor AnalysisLimitsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor> AnalysisLimitsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Duration? BackgroundPersistIntervalValue { get; set; }
	private object? CustomSettingsValue { get; set; }
	private long? DailyModelSnapshotRetentionAfterDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataDescription DataDescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor<TDocument> DataDescriptionDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor<TDocument>> DataDescriptionDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfig? DatafeedConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor<TDocument> DatafeedConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor<TDocument>> DatafeedConfigDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private ICollection<string>? GroupsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? ModelPlotConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor<TDocument> ModelPlotConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor<TDocument>> ModelPlotConfigDescriptorAction { get; set; }
	private long? ModelSnapshotRetentionDaysValue { get; set; }
	private long? RenormalizationWindowDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexName? ResultsIndexNameValue { get; set; }
	private long? ResultsRetentionDaysValue { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. Specifies whether this job can open when there is insufficient machine learning node capacity for it to be immediately assigned to a node. By default, if a machine learning node with capacity to run the job cannot immediately be found, the open anomaly detection jobs API returns an error. However, this is also subject to the cluster-wide <c>xpack.ml.max_lazy_ml_nodes</c> setting. If this option is set to true, the open anomaly detection jobs API does not return an error and the job waits in the opening state until sufficient machine learning node capacity is available.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> AllowLazyOpen(bool? allowLazyOpen = true)
	{
		AllowLazyOpenValue = allowLazyOpen;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> AnalysisConfig(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfig analysisConfig)
	{
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigValue = analysisConfig;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> AnalysisConfig(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor<TDocument> descriptor)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> AnalysisConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor<TDocument>> configure)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Limits can be applied for the resources required to hold the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> AnalysisLimits(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits? analysisLimits)
	{
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsValue = analysisLimits;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> AnalysisLimits(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor descriptor)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> AnalysisLimits(Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor> configure)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The time between each periodic persistence of the model. The default value is a randomized value between 3 to 4 hours, which avoids all jobs persisting at exactly the same time. The smallest allowed value is 1 hour. For very large models (several GB), persistence could take 10-20 minutes, so do not set the <c>background_persist_interval</c> value too low.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> BackgroundPersistInterval(Elastic.Clients.Elasticsearch.Duration? backgroundPersistInterval)
	{
		BackgroundPersistIntervalValue = backgroundPersistInterval;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. Contains custom meta data about the job.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> CustomSettings(object? customSettings)
	{
		CustomSettingsValue = customSettings;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies a period of time (in days) after which only the first snapshot per day is retained. This period is relative to the timestamp of the most recent snapshot for this job. Valid values range from 0 to <c>model_snapshot_retention_days</c>.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> DailyModelSnapshotRetentionAfterDays(long? dailyModelSnapshotRetentionAfterDays)
	{
		DailyModelSnapshotRetentionAfterDaysValue = dailyModelSnapshotRetentionAfterDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post data API, it is not stored in Elasticsearch. Only the results for anomaly detection are retained.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> DataDescription(Elastic.Clients.Elasticsearch.MachineLearning.DataDescription dataDescription)
	{
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionValue = dataDescription;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> DataDescription(Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor<TDocument> descriptor)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> DataDescription(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor<TDocument>> configure)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Defines a datafeed for the anomaly detection job. If Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had at the time of creation and runs the query using those same roles. If you provide secondary authorization headers, those credentials are used instead.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> DatafeedConfig(Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfig? datafeedConfig)
	{
		DatafeedConfigDescriptor = null;
		DatafeedConfigDescriptorAction = null;
		DatafeedConfigValue = datafeedConfig;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> DatafeedConfig(Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor<TDocument> descriptor)
	{
		DatafeedConfigValue = null;
		DatafeedConfigDescriptorAction = null;
		DatafeedConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> DatafeedConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor<TDocument>> configure)
	{
		DatafeedConfigValue = null;
		DatafeedConfigDescriptor = null;
		DatafeedConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A description of the job.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A list of job groups. A job can belong to no groups or many.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> Groups(ICollection<string>? groups)
	{
		GroupsValue = groups;
		return Self;
	}

	/// <summary>
	/// <para>
	/// This advanced configuration option stores model information along with the results. It provides a more detailed view into anomaly detection. If you enable model plot it can add considerable overhead to the performance of the system; it is not feasible for jobs with many entities. Model plot provides a simplified and indicative view of the model and its bounds. It does not display complex features such as multivariate correlations or multimodal data. As such, anomalies may occasionally be reported which cannot be seen in the model plot. Model plot config can be configured when the job is created or updated later. It must be disabled if performance issues are experienced.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> ModelPlotConfig(Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? modelPlotConfig)
	{
		ModelPlotConfigDescriptor = null;
		ModelPlotConfigDescriptorAction = null;
		ModelPlotConfigValue = modelPlotConfig;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> ModelPlotConfig(Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor<TDocument> descriptor)
	{
		ModelPlotConfigValue = null;
		ModelPlotConfigDescriptorAction = null;
		ModelPlotConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor<TDocument> ModelPlotConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor<TDocument>> configure)
	{
		ModelPlotConfigValue = null;
		ModelPlotConfigDescriptor = null;
		ModelPlotConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies the maximum period of time (in days) that snapshots are retained. This period is relative to the timestamp of the most recent snapshot for this job. By default, snapshots ten days older than the newest snapshot are deleted.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> ModelSnapshotRetentionDays(long? modelSnapshotRetentionDays)
	{
		ModelSnapshotRetentionDaysValue = modelSnapshotRetentionDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period over which adjustments to the score are applied, as new data is seen. The default value is the longer of 30 days or 100 bucket spans.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> RenormalizationWindowDays(long? renormalizationWindowDays)
	{
		RenormalizationWindowDaysValue = renormalizationWindowDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A text string that affects the name of the machine learning results index. By default, the job generates an index named <c>.ml-anomalies-shared</c>.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> ResultsIndexName(Elastic.Clients.Elasticsearch.IndexName? resultsIndexName)
	{
		ResultsIndexNameValue = resultsIndexName;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period of time (in days) that results are retained. Age is calculated relative to the timestamp of the latest bucket result. If this property has a non-null value, once per day at 00:30 (server time), results that are the specified number of days older than the latest bucket result are deleted from Elasticsearch. The default value is null, which means all results are retained. Annotations generated by the system also count as results for retention purposes; they are deleted after the same number of days as results. Annotations added by users are retained forever.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor<TDocument> ResultsRetentionDays(long? resultsRetentionDays)
	{
		ResultsRetentionDaysValue = resultsRetentionDays;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowLazyOpenValue.HasValue)
		{
			writer.WritePropertyName("allow_lazy_open");
			writer.WriteBooleanValue(AllowLazyOpenValue.Value);
		}

		if (AnalysisConfigDescriptor is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigDescriptor, options);
		}
		else if (AnalysisConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor<TDocument>(AnalysisConfigDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigValue, options);
		}

		if (AnalysisLimitsDescriptor is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsDescriptor, options);
		}
		else if (AnalysisLimitsDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor(AnalysisLimitsDescriptorAction), options);
		}
		else if (AnalysisLimitsValue is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsValue, options);
		}

		if (BackgroundPersistIntervalValue is not null)
		{
			writer.WritePropertyName("background_persist_interval");
			JsonSerializer.Serialize(writer, BackgroundPersistIntervalValue, options);
		}

		if (CustomSettingsValue is not null)
		{
			writer.WritePropertyName("custom_settings");
			JsonSerializer.Serialize(writer, CustomSettingsValue, options);
		}

		if (DailyModelSnapshotRetentionAfterDaysValue.HasValue)
		{
			writer.WritePropertyName("daily_model_snapshot_retention_after_days");
			writer.WriteNumberValue(DailyModelSnapshotRetentionAfterDaysValue.Value);
		}

		if (DataDescriptionDescriptor is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionDescriptor, options);
		}
		else if (DataDescriptionDescriptorAction is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor<TDocument>(DataDescriptionDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionValue, options);
		}

		if (DatafeedConfigDescriptor is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, DatafeedConfigDescriptor, options);
		}
		else if (DatafeedConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor<TDocument>(DatafeedConfigDescriptorAction), options);
		}
		else if (DatafeedConfigValue is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, DatafeedConfigValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (GroupsValue is not null)
		{
			writer.WritePropertyName("groups");
			JsonSerializer.Serialize(writer, GroupsValue, options);
		}

		if (ModelPlotConfigDescriptor is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, ModelPlotConfigDescriptor, options);
		}
		else if (ModelPlotConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor<TDocument>(ModelPlotConfigDescriptorAction), options);
		}
		else if (ModelPlotConfigValue is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, ModelPlotConfigValue, options);
		}

		if (ModelSnapshotRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("model_snapshot_retention_days");
			writer.WriteNumberValue(ModelSnapshotRetentionDaysValue.Value);
		}

		if (RenormalizationWindowDaysValue.HasValue)
		{
			writer.WritePropertyName("renormalization_window_days");
			writer.WriteNumberValue(RenormalizationWindowDaysValue.Value);
		}

		if (ResultsIndexNameValue is not null)
		{
			writer.WritePropertyName("results_index_name");
			JsonSerializer.Serialize(writer, ResultsIndexNameValue, options);
		}

		if (ResultsRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("results_retention_days");
			writer.WriteNumberValue(ResultsRetentionDaysValue.Value);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>
/// Create an anomaly detection job.
/// If you include a <c>datafeed_config</c>, you must have read index privileges on the source index.
/// </para>
/// </summary>
public sealed partial class PutJobRequestDescriptor : RequestDescriptor<PutJobRequestDescriptor, PutJobRequestParameters>
{
	internal PutJobRequestDescriptor(Action<PutJobRequestDescriptor> configure) => configure.Invoke(this);

	public PutJobRequestDescriptor(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Required("job_id", jobId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutJob;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_job";

	public PutJobRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Id jobId)
	{
		RouteValues.Required("job_id", jobId);
		return Self;
	}

	private bool? AllowLazyOpenValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfig AnalysisConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor AnalysisConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor> AnalysisConfigDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits? AnalysisLimitsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor AnalysisLimitsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor> AnalysisLimitsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Duration? BackgroundPersistIntervalValue { get; set; }
	private object? CustomSettingsValue { get; set; }
	private long? DailyModelSnapshotRetentionAfterDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataDescription DataDescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor DataDescriptionDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor> DataDescriptionDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfig? DatafeedConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor DatafeedConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor> DatafeedConfigDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private ICollection<string>? GroupsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? ModelPlotConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor ModelPlotConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor> ModelPlotConfigDescriptorAction { get; set; }
	private long? ModelSnapshotRetentionDaysValue { get; set; }
	private long? RenormalizationWindowDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexName? ResultsIndexNameValue { get; set; }
	private long? ResultsRetentionDaysValue { get; set; }

	/// <summary>
	/// <para>
	/// Advanced configuration option. Specifies whether this job can open when there is insufficient machine learning node capacity for it to be immediately assigned to a node. By default, if a machine learning node with capacity to run the job cannot immediately be found, the open anomaly detection jobs API returns an error. However, this is also subject to the cluster-wide <c>xpack.ml.max_lazy_ml_nodes</c> setting. If this option is set to true, the open anomaly detection jobs API does not return an error and the job waits in the opening state until sufficient machine learning node capacity is available.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor AllowLazyOpen(bool? allowLazyOpen = true)
	{
		AllowLazyOpenValue = allowLazyOpen;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor AnalysisConfig(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfig analysisConfig)
	{
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigValue = analysisConfig;
		return Self;
	}

	public PutJobRequestDescriptor AnalysisConfig(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor descriptor)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor AnalysisConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor> configure)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Limits can be applied for the resources required to hold the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor AnalysisLimits(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits? analysisLimits)
	{
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsValue = analysisLimits;
		return Self;
	}

	public PutJobRequestDescriptor AnalysisLimits(Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor descriptor)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor AnalysisLimits(Action<Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor> configure)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The time between each periodic persistence of the model. The default value is a randomized value between 3 to 4 hours, which avoids all jobs persisting at exactly the same time. The smallest allowed value is 1 hour. For very large models (several GB), persistence could take 10-20 minutes, so do not set the <c>background_persist_interval</c> value too low.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor BackgroundPersistInterval(Elastic.Clients.Elasticsearch.Duration? backgroundPersistInterval)
	{
		BackgroundPersistIntervalValue = backgroundPersistInterval;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. Contains custom meta data about the job.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor CustomSettings(object? customSettings)
	{
		CustomSettingsValue = customSettings;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies a period of time (in days) after which only the first snapshot per day is retained. This period is relative to the timestamp of the most recent snapshot for this job. Valid values range from 0 to <c>model_snapshot_retention_days</c>.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor DailyModelSnapshotRetentionAfterDays(long? dailyModelSnapshotRetentionAfterDays)
	{
		DailyModelSnapshotRetentionAfterDaysValue = dailyModelSnapshotRetentionAfterDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post data API, it is not stored in Elasticsearch. Only the results for anomaly detection are retained.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor DataDescription(Elastic.Clients.Elasticsearch.MachineLearning.DataDescription dataDescription)
	{
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionValue = dataDescription;
		return Self;
	}

	public PutJobRequestDescriptor DataDescription(Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor descriptor)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor DataDescription(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor> configure)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Defines a datafeed for the anomaly detection job. If Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had at the time of creation and runs the query using those same roles. If you provide secondary authorization headers, those credentials are used instead.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor DatafeedConfig(Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfig? datafeedConfig)
	{
		DatafeedConfigDescriptor = null;
		DatafeedConfigDescriptorAction = null;
		DatafeedConfigValue = datafeedConfig;
		return Self;
	}

	public PutJobRequestDescriptor DatafeedConfig(Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor descriptor)
	{
		DatafeedConfigValue = null;
		DatafeedConfigDescriptorAction = null;
		DatafeedConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor DatafeedConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor> configure)
	{
		DatafeedConfigValue = null;
		DatafeedConfigDescriptor = null;
		DatafeedConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A description of the job.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A list of job groups. A job can belong to no groups or many.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor Groups(ICollection<string>? groups)
	{
		GroupsValue = groups;
		return Self;
	}

	/// <summary>
	/// <para>
	/// This advanced configuration option stores model information along with the results. It provides a more detailed view into anomaly detection. If you enable model plot it can add considerable overhead to the performance of the system; it is not feasible for jobs with many entities. Model plot provides a simplified and indicative view of the model and its bounds. It does not display complex features such as multivariate correlations or multimodal data. As such, anomalies may occasionally be reported which cannot be seen in the model plot. Model plot config can be configured when the job is created or updated later. It must be disabled if performance issues are experienced.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor ModelPlotConfig(Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? modelPlotConfig)
	{
		ModelPlotConfigDescriptor = null;
		ModelPlotConfigDescriptorAction = null;
		ModelPlotConfigValue = modelPlotConfig;
		return Self;
	}

	public PutJobRequestDescriptor ModelPlotConfig(Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor descriptor)
	{
		ModelPlotConfigValue = null;
		ModelPlotConfigDescriptorAction = null;
		ModelPlotConfigDescriptor = descriptor;
		return Self;
	}

	public PutJobRequestDescriptor ModelPlotConfig(Action<Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor> configure)
	{
		ModelPlotConfigValue = null;
		ModelPlotConfigDescriptor = null;
		ModelPlotConfigDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option, which affects the automatic removal of old model snapshots for this job. It specifies the maximum period of time (in days) that snapshots are retained. This period is relative to the timestamp of the most recent snapshot for this job. By default, snapshots ten days older than the newest snapshot are deleted.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor ModelSnapshotRetentionDays(long? modelSnapshotRetentionDays)
	{
		ModelSnapshotRetentionDaysValue = modelSnapshotRetentionDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period over which adjustments to the score are applied, as new data is seen. The default value is the longer of 30 days or 100 bucket spans.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor RenormalizationWindowDays(long? renormalizationWindowDays)
	{
		RenormalizationWindowDaysValue = renormalizationWindowDays;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A text string that affects the name of the machine learning results index. By default, the job generates an index named <c>.ml-anomalies-shared</c>.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor ResultsIndexName(Elastic.Clients.Elasticsearch.IndexName? resultsIndexName)
	{
		ResultsIndexNameValue = resultsIndexName;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Advanced configuration option. The period of time (in days) that results are retained. Age is calculated relative to the timestamp of the latest bucket result. If this property has a non-null value, once per day at 00:30 (server time), results that are the specified number of days older than the latest bucket result are deleted from Elasticsearch. The default value is null, which means all results are retained. Annotations generated by the system also count as results for retention purposes; they are deleted after the same number of days as results. Annotations added by users are retained forever.
	/// </para>
	/// </summary>
	public PutJobRequestDescriptor ResultsRetentionDays(long? resultsRetentionDays)
	{
		ResultsRetentionDaysValue = resultsRetentionDays;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowLazyOpenValue.HasValue)
		{
			writer.WritePropertyName("allow_lazy_open");
			writer.WriteBooleanValue(AllowLazyOpenValue.Value);
		}

		if (AnalysisConfigDescriptor is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigDescriptor, options);
		}
		else if (AnalysisConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigDescriptor(AnalysisConfigDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigValue, options);
		}

		if (AnalysisLimitsDescriptor is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsDescriptor, options);
		}
		else if (AnalysisLimitsDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimitsDescriptor(AnalysisLimitsDescriptorAction), options);
		}
		else if (AnalysisLimitsValue is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsValue, options);
		}

		if (BackgroundPersistIntervalValue is not null)
		{
			writer.WritePropertyName("background_persist_interval");
			JsonSerializer.Serialize(writer, BackgroundPersistIntervalValue, options);
		}

		if (CustomSettingsValue is not null)
		{
			writer.WritePropertyName("custom_settings");
			JsonSerializer.Serialize(writer, CustomSettingsValue, options);
		}

		if (DailyModelSnapshotRetentionAfterDaysValue.HasValue)
		{
			writer.WritePropertyName("daily_model_snapshot_retention_after_days");
			writer.WriteNumberValue(DailyModelSnapshotRetentionAfterDaysValue.Value);
		}

		if (DataDescriptionDescriptor is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionDescriptor, options);
		}
		else if (DataDescriptionDescriptorAction is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataDescriptionDescriptor(DataDescriptionDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionValue, options);
		}

		if (DatafeedConfigDescriptor is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, DatafeedConfigDescriptor, options);
		}
		else if (DatafeedConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DatafeedConfigDescriptor(DatafeedConfigDescriptorAction), options);
		}
		else if (DatafeedConfigValue is not null)
		{
			writer.WritePropertyName("datafeed_config");
			JsonSerializer.Serialize(writer, DatafeedConfigValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (GroupsValue is not null)
		{
			writer.WritePropertyName("groups");
			JsonSerializer.Serialize(writer, GroupsValue, options);
		}

		if (ModelPlotConfigDescriptor is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, ModelPlotConfigDescriptor, options);
		}
		else if (ModelPlotConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfigDescriptor(ModelPlotConfigDescriptorAction), options);
		}
		else if (ModelPlotConfigValue is not null)
		{
			writer.WritePropertyName("model_plot_config");
			JsonSerializer.Serialize(writer, ModelPlotConfigValue, options);
		}

		if (ModelSnapshotRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("model_snapshot_retention_days");
			writer.WriteNumberValue(ModelSnapshotRetentionDaysValue.Value);
		}

		if (RenormalizationWindowDaysValue.HasValue)
		{
			writer.WritePropertyName("renormalization_window_days");
			writer.WriteNumberValue(RenormalizationWindowDaysValue.Value);
		}

		if (ResultsIndexNameValue is not null)
		{
			writer.WritePropertyName("results_index_name");
			JsonSerializer.Serialize(writer, ResultsIndexNameValue, options);
		}

		if (ResultsRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("results_retention_days");
			writer.WriteNumberValue(ResultsRetentionDaysValue.Value);
		}

		writer.WriteEndObject();
	}
}